<!DOCTYPE html>
<script id="firstScript" type="invalid">
    // When this script runs p.parentNode == null because we're in the middle of
    // an HTMLConstructionSite::insert() task from the adoption agency.
    s.appendChild(p);
</script>
<b>
    <p id="paragraph">
        <script>
             p = document.getElementById("paragraph");
             s = document.getElementById("firstScript");
             s.appendChild(p);
             s.type = "";
         </script>
    <!-- End tag omitted for implicit close -->
</b>
<script>
    if (window.testRunner)
        testRunner.dumpAsText();
    p.remove();
    var p = document.querySelector("p");
    if (p) {
        document.body.textContent = "FAIL, " + p.tagName + " has parentNode = " + p.parentNode;
    } else {
        document.body.textContent = "PASS";
    }
</script>
